import { createSlice } from "@reduxjs/toolkit";
import { UserState } from "../interface";

const userState: UserState = {
	userInfo: {},
	token: ""
};

export const userSlice = createSlice({
	name: "user",
	initialState: userState,
	reducers: {
		setToken(state, action) {
			state.token = action.payload;
			console.log(state.token, action);
			localStorage.setItem("token", action.payload);
		}
	}
});

export const { setToken } = userSlice.actions;
export default userSlice.reducer;
